<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>class的私有性</title>
</head>

<body>
    <script>
        // 模拟私有属性
        // class people {
        //     constructor(name) {
        //         this._name = name;
        //     }
        //     getname() {
        //         return this._name
        //     }
        // }
        // const x = new people('gu');
        // console.log(x.name)
        // console.log(x.getname())
            (function () {
                let name='';
                class people {
                    constructor(urename) {
                       name = urename;
                    }
                    getname(){
                        return name

                    }
                }
                window.people= people;
               
            }
            )();
            
            (function(){
                var p=new people('gu')
                console.log(p.getname());
                console.log(name)

            })();
            
    </script>
</body>

</html>